package com.gitee.ywj1352.client;


import com.gitee.ywj1352.common.message.ResponseMessage;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class RequestPendingCenter {

    private Map<Long, YWJResultFuture> map = new ConcurrentHashMap<>();

    public void add(Long streamId, YWJResultFuture future) {
        this.map.put(streamId, future);
    }

    public void set(Long streamId, ResponseMessage operationResult) {
        YWJResultFuture operationResultFuture = this.map.get(streamId);
        if (operationResultFuture != null) {
            operationResultFuture.setSuccess(operationResult);
            this.map.remove(streamId);
        }
    }

}
